<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="hmg.common.CommonUtils"%>
<%@ page import="hmg.vo.BoardVO"%>
<%@ page import="java.util.List"%>
<%-- 
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 9. 20.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 9. 20.     Kim hyung soo     최초 생성
--%>
<%
    String currPage = CommonUtils.getParameter(request.getParameter("page"), "1");
    String totalSearches = CommonUtils.getParameter(request.getParameter("totalSearches"), "0");
    String dicts = CommonUtils.getParameter(request.getParameter("dicts"), "0");
    String news = CommonUtils.getParameter(request.getParameter("news"), "0");
    String acts = CommonUtils.getParameter(request.getParameter("acts"), "0");
    String recs = CommonUtils.getParameter(request.getParameter("recs"), "0");
    String vods = CommonUtils.getParameter(request.getParameter("vods"), "0");
    String photos = CommonUtils.getParameter(request.getParameter("photos"), "0");
    String searchKeyword = CommonUtils.getDecodedParameter(request.getParameter("searchKeyword"), "");

    List<BoardVO> photoList = (List<BoardVO>) request.getAttribute("PhotoList");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>통합검색 | 현대자동차그룹</title>
<meta name="description" content="현대자동차그룹 홈페이지 내 통합 검색하기" />
<meta name="keywords" content="현대자동차그룹 통합검색, 현대차그룹, 통합검색, 통합검색, 검색" />
<%@ include file="/WEB-INF/jsp/web/kor/include/header.jspf" %>
<script type="text/javascript">
var page = "<%= currPage %>";
var totalSearches = "<%= totalSearches %>";
var dicts = "<%= dicts %>";
var news = "<%= news %>";
var acts = "<%= acts %>";
var recs = "<%= recs %>";
var vods = "<%= vods %>";
var photos = "<%= photos %>";

$(document).ready(function(){
    if (page == "")
        page = "1";

    $("#paging").html(getNewsPagingString(<%= photos %>, page, 10, 10)); 
});

function fn_search() {
    var keyword = $("#searchKeyword").val();
    
    if (keyword == "") {
        alert("검색어를 입력해 주세요.");
        return;
    }
    else if (keyword.length < 2) {
        alert("검색어를 2자 이상 입력해 주세요.");
        return;
    }

    document.location.href = "./UnifiedSearch.do?searchKeyword=" + escape(encodeURIComponent(keyword)) + "&page=1";
}

function fn_search_result(listType) {
    var keyword = escape(encodeURIComponent($("#searchKeyword").val()));
    
    switch (listType) {
        case 0 : document.location.href = "/hmg/web/kor/sch/trm/TermDictionaryList.do?searchKeyword=" + keyword; break;
        case 1 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearch.do?searchKeyword=" + keyword; break;
        case 2 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchNews.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 3 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchAct.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 4 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchRecruit.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 5 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchVod.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
        case 6 : document.location.href = "/hmg/web/kor/sch/nfd/UnifiedSearchPhoto.do?searchKeyword=" + keyword + "&totalSearches=" + totalSearches + "&dicts=" + dicts + "&news=" + news + "&acts=" + acts + "&recs=" + recs + "&vods=" + vods + "&photos=" + photos + "&page=1"; break;
    }
}

function fn_move_page(pageNo){
    fn_common_move_page(pageNo, location.search, page, 10, <%= photos %>, "./UnifiedSearchPhoto.do");
}

//이미지갤러리
$(function() {
    usrAgnt = navigator.userAgent;

    var totalPanels = $(".photo_scrollContainer").children().size();
    var movingDistance  = 600;
    var $panels = $('#photo_gallery_slider .photo_scrollContainer > div');
    var $container = $('#photo_gallery_slider .photo_scrollContainer');
    var curPanel = 0;
    var scroll = $('#photo_gallery_slider .photo_gallery_scroll').css('overflow', 'hidden');
    $panels.css({'float' : 'left','position' : 'relative'});
    $container.css({'width': (600* $panels.size()) +'px', 'left':'0px'});
    $("#photo_gallery_slider").data("currentlyMoving", false);

    function change(direction, moveIndex) {
        if((direction && !(curPanel < totalPanels - 1)) || (!direction && (curPanel <= 0))) { return false; }
        if (($("#photo_gallery_slider").data("currentlyMoving") == false)) {
            $("#photo_gallery_slider").data("currentlyMoving", true);
            var next = direction ? curPanel + moveIndex : curPanel - moveIndex;
            var leftValue = $(".photo_scrollContainer").css("left");
            var movement = direction ? parseFloat(leftValue, 10) - (movingDistance * moveIndex) : parseFloat(leftValue, 10) + (movingDistance * moveIndex);
            var curThumb = $("#galley_thumbImg li.on");
            var removeClassEl = direction ? $(curThumb).next() : $(curThumb).prev();
            $(".photo_scrollContainer").stop().animate({"left": movement}, 300, function() {
                $("#photo_gallery_slider").data("currentlyMoving", false);
            });
            $(removeClassEl).addClass("on");
            $(curThumb).removeClass("on");
            curPanel = next;
        }
    }

    $("#galley_thumbImg li").live("click", function(){
        if(!($(".photo_scrollContainer").is(":animated"))){
            var curElSize = $("#galley_thumbImg li.on").index();
            var clickElSize = $(this).index();
            if(curElSize !== clickElSize){
                if(curElSize > clickElSize){
                    change(false, (curElSize-clickElSize));
                }
                else if(curElSize < clickElSize){
                    change(true, (clickElSize-curElSize));
                }
                curPanel = clickElSize;
                $("#galley_thumbImg li").removeClass("on");
                $(this).addClass("on");
            }
        }
    });

    $(".galleryRight").live("click", function(){
        change(true, 1);
    });
    $(".galleryLeft").live("click", function(){
        change(false, 1);
    });

    $(".photo_gallery_panel img").live("click", function(){
        $(".photo_gallery_Information").toggle();
    });

    if(usrAgnt.indexOf("Mobile") < 0){
        $(".photo_layOpen").each(function(){
            $(this).find(".photo_layOver").hide().animate({"top":"162px","opacity": "1"}).stop(true, true);
            $(this).find(".bg").show();
        });

     $(".photo_layOpen").live({
            mouseover : function(){
            $(this).find(".photo_layOver").css("display","block").animate({"top":"118px","opacity": ".8" });
                $(this).find(".bg").hide();
          },
          mouseleave : function(){
            $(this).find(".photo_layOver").css("display","none").animate({"top":"162px","opacity": "1"}).stop(true, true);
                $(this).find(".bg").show();
          }
        });
    }
});

function fn_view_photo(listID) {
    $("#photoLayer").html("");
      
    $.ajax({
        type:"post",
        url:"./AjaxPhotoView.do",
        data:({listID:listID}),
        success: function(data) { fn_view_photo_proc(data); }
    });
}

function fn_view_photo_proc(data) {
    $("#photoLayer").html(data);
  
    fe_layPop();
  
    $("#noticeWrap").css({"z-index":"-1"});
    $("#footer").css({"z-index":"-2"});

    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    var layerHeight = $(".photo_layPop > div").height();
    var layerWidth = $(".photo_layPop > div").width();
    $(".photo_layer").css({"width":maskWidth,"height":maskHeight, "display": "block"});
    $(".photo_layPop").css({"margin-top": "-" + layerHeight/2 + "px", "margin-left" : "-" + layerWidth/2 + "px"});
}

function playerSoundOff() {}

</script>
</head>
<body>
<!--wrap-->
<div id="wrap">
    <!-- skip navigation -->
    <div id="skipnavition">
        <a href="#gnb">메뉴바로가기</a><a href="#content">본문바로가기</a>
    </div>
    <!--// skip navigation -->

    <hr />

    <!-- header-->
    <%@ include file="/WEB-INF/jsp/web/kor/include/left.jspf" %>
    <!--//header-->

    <hr />

    <!--container-->
    <div id="container">
        <div class="scroll-pane">
            <!-- 공통 -->
            <div class="subTitle">
                <div class="pageTitle">
                    <h2><img src="/hmg/images/web/kor/title/sch_Totalsearch.gif" alt="통합검색" /></h2>
                </div> 

                <div class="pageLocation">
                    <ul>
                        <li><a href="/hmg/web/kor/Main.do"><img src="/hmg/images/web/kor/common/location_home.gif" alt="홈"/></a></li>
                        <li class="nowPage"><a href="/hmg/web/kor/sch/nfd/UnifiedSearch.do">통합검색</a></li>
                    </ul>
                </div>
            </div>
            <!--//공통-->

            <!--contents-->
            <div id="content">

                <!-- 내용 -->
                <div class="total_search">
                    
                    <div class="total_searchBox">
                        <img src="/hmg/images/web/kor/sch/total_Search_Text01.gif" alt="상세검색" class="search_text"/>
                        <label class="hidden" for="searchKeyword">검색</label>
                        <input type="text" title="검색" id="searchKeyword" name="searchKeyword" value="<%= searchKeyword %>" onkeypress="javascript:if (event.keyCode==13) {fn_search();}" maxlength="50"/>
                        <a href="javascript:fn_search();"><img src="/hmg/images/web/kor/btn/btn_search.gif" alt="검색"  class="btn"/></a>
                    </div>

<%  if (searchKeyword != "") { %>
                    <p class="total_search_result">&quot;<span><%= searchKeyword %></span>&quot; 에 대한 검색결과가 총 <span><%= totalSearches %></span>건이 있습니다.</p>
<%  } %>
                
                    <div class="total_searchTab">
                        <ul class="tabs">
                            <li class="tab1"><a href="#" onclick="javascript:fn_search_result(1);">통합검색 (<span class="count"><%= totalSearches %></span>)</a></li>
                            <li class="tab2"><a href="#" onclick="javascript:fn_search_result(2);">그룹소식 (<span class="count"><%= news %></span>)</a></li>
                            <li class="tab3"><a href="#" onclick="javascript:fn_search_result(3);" >사회공헌 (<span class="count"><%= acts %></span>)</a></li>
                            <li class="tab4"><a href="#" onclick="javascript:fn_search_result(4);">인재채용 (<span class="count"><%= recs %></span>)</a></li>
                            <li class="tab5"><a href="#" onclick="javascript:fn_search_result(5);">영상 (<span class="count"><%= vods %></span>)</a></li>
                            <li class="tab6"><a href="#" onclick="javascript:fn_search_result(6);" class="on">이미지 (<span class="count"><%= photos %></span>)</a></li>
                        </ul>
                    </div>

                    <!-- tabCont6  S// -->
                    <div id="tab_content06" class="tab_content">
                        <div class="titleWrap">
                            <div class="left"><h3>이미지 (<span class="list_count"><%= photos %>건</span>)</h3></div>
                        </div>
                        <div class="search_result_gallery">
<%  if (photoList == null || photoList.size() == 0) { %>
                            
                                </br><dl class="photo_layOpen" style="text-align:center;width:100%;">검색된 게시물이 없습니다.</dl>
<%
    }
    else {
        for (int idx = 0; idx < photoList.size(); idx++) {
            BoardVO searchPhoto = photoList.get(idx);
    
            String dlClassName = "";
    
            if ((idx + 1) % 4 == 0)
                dlClassName = " last";
%>
                            <dl class="<%= dlClassName %>">
                                <dt><a href="#" onclick="javascript:fn_view_photo(<%= searchPhoto.getListID() %>);" class="photo_layOpen"><%= searchPhoto.getTitle() %></a></dt>
                                <dd class="etc_information"><span>사진갤러리</span><%= searchPhoto.getRegDate() %></dd>
                                <dd class="gallery_image"><a href="#" onclick="javascript:fn_view_photo(<%= searchPhoto.getListID() %>);" class="photo_layOpen"><img src="<%= searchPhoto.getThumbnailImage() %>" style="width:146px; height:146px; border:0px;" alt="사진갤러리 검색결과 이미지"/></a></dd>
                            </dl>
<%
        }
    }
%>
                        </div>

                        <div class="gropnews_page mt20">
                            <div class="gropnews_page_left">
                                <ul id="paging"></ul>
                            </div>

                            <div class="gropnews_page_right">
                                <ul>
                                    <li><a href="javascript:fn_move_page('prev');"><img src="/hmg/images/web/kor/btn/btn_prev.gif" alt="이전페이지로 이동" /></a></li>
                                    <li><a href="javascript:fn_move_page('next');"><img src="/hmg/images/web/kor/btn/btn_next.gif" alt="다음페이지로 이동" /></a></li>
                                </ul>
                            </div>
                        </div>

                    </div>
                    <!-- tabCont6  E// -->
                </div>  
            </div>
            <!--// 내용 -->
            
            <!-- 이미지layer -->
            <div class="photo_layer" id="photoLayer">
                <div class="photo_mask"></div>
                <div class="photo_layPop">
                    <p class="btnClose"><a href="#"><img src="/hmg/images/web/kor/mgr/gallery_Slide_Close.png" alt="닫기"/></a></p>

                    <div class="galleryView">

                        <span class="galleryLeft"><img class="png24" src="/hmg/images/web/kor/grn/btn_galleryView_Left.png" alt="left"/></span>
                            <div id="photo_gallery_wrapper">
                                <div id="photo_gallery_slider">
                                    <div style="overflow: hidden;" class="photo_gallery_scroll">
                                        <div class="photo_scrollContainer">
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide01.jpg" alt="" />
                                                <div class="photo_gallery_Information">
                                                    <p class="categoty"></p>
                                                    <p class="title"></p>
                                                </div>
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide02.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide03.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide04.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide05.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide06.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide07.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide08.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide07.jpg" alt="" />
                                            </div>
                                            <div class="photo_gallery_panel">
                                                <img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide08.jpg" alt="" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <span class="galleryRight"><img class="png24"src="/hmg/images/web/kor/grn/btn_galleryView_Right.png" alt="right"/></span>

                            <div id="galley_thumbImg">
                                <ul>
                                    <li class="on"><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide01.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide02.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide03.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide04.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide05.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide06.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide07.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide08.jpg" alt="" /></li>
                                    <li><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide07.jpg" alt="" /></li>
                                    <li class="last"><img src="http://www.kiamotors.com/vehicles/rio/images/IpadApp/iPadAppSlide08.jpg" alt="" /></li>
                                </ul>

                        </div>

                    </div>
                </div>
            </div>
            <!-- /이미지layer -->
            
        </div>
        <!--//contents-->
    </div>
    <!--//container-->

    <hr />

    <!--footer-->
    <%@ include file="/WEB-INF/jsp/web/kor/include/footer.jspf" %>
    <!--//footer-->
    <hr />
    <!--notice-->
    <%@ include file="/WEB-INF/jsp/web/kor/include/notice.jspf" %>
    <!--//notice-->
</div>
<!--//wrap-->
</body>
</html>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       